package com.cea.papyrus.core.actions.selectcopypaste;

import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.gef.ui.actions.SelectionAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.IWorkbenchPart;

import com.cea.papyrus.core.editor.ModelManager;

/**
 * Abstract class that should be overridden by actions driven by selection in the Papyrus Modeler
 */
public abstract class PapyrusSelectionAction extends SelectionAction {

	/** instance for the editing domain used by the action */
	protected final EditingDomain editingDomain;

	/**
	 * Creates a new PapyrusSelectionAction.
	 * @param part The workbench part associated with this action
	 */
	public PapyrusSelectionAction(IWorkbenchPart part) {
		super(part);
		// adapts the part to the model manager
		ModelManager manager = (ModelManager)part.getAdapter(ModelManager.class);
		editingDomain = manager.getDiResourceSet().getEditingDomain();
	}

	/**
	 * Creates a new PapyrusSelectionAction.
	 * @param part the workbench part associated with this action
	 * @param style the style for this action
	 */
	public PapyrusSelectionAction(IWorkbenchPart part, int style) {
		super(part, style);
		// adapts the part to the model manager
		ModelManager manager = (ModelManager)part.getAdapter(ModelManager.class);
		editingDomain = manager.getDiResourceSet().getEditingDomain();
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public void setSelection(ISelection selection) {
		// overrides for visibility
		super.setSelection(selection);
	}

}
